package com.java2104.controller;

import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

//@ControllerAdvice//一个全局控制器的注解
public class GlobalExceptionHandler {
    //统一异常处理
   @ExceptionHandler(Exception.class)
    public  String handle(Exception ex,Model model){
       model.addAttribute("err_msg","对不起，程序出错"+ex.getMessage());
       return "500";
   }
}
